		TITLE	GETTIME - Copyright (c) SLR Systems 1994

		INCLUDE	MACROS
		INCLUDE	WIN32DEF

		PUBLIC	GET_TIME_AND_DATE


		.DATA

		EXTERNDEF	CURN_HOUR:BYTE,CURN_MINUTE:BYTE,CURN_SECOND:BYTE,CURN_HUNDREDTH:BYTE,CURN_MONTH:BYTE,CURN_DAY:BYTE

		EXTERNDEF	CURN_YEAR:DWORD,CURN_DATE_DWD:DWORD,CURN_TIME_DWD:DWORD


		.CODE	ROOT_TEXT


GET_TIME_AND_DATE	PROC
		;
		;
		;
		PUSH	OFF SYSTEM_TIME
		CALL	GetLocalTime

		PUSH	EBX
		MOV	EBX,OFF SYSTEM_TIME
		ASSUME	EBX:PTR SYSTEMTIME

		MOV	EAX,DPTR [EBX].WYEAR
		MOV	DL,BPTR [EBX].WDAY

		MOV	DH,BPTR [EBX].WMONTH
		AND	EAX,0FFFFH

		MOV	CURN_MONTH,DH
		MOV	CURN_DAY,DL

		MOV	CURN_YEAR,EAX
		SUB	EAX,1980

		XOR	ECX,ECX

		SHL	EAX,9
		MOV	CL,DH

		AND	DL,1FH

		SHL	ECX,5
		OR	AL,DL

		OR	EAX,ECX

		MOV	CURN_DATE_DWD,EAX

		MOV	AX,[EBX].WMILLISECONDS
		MOV	DL,10

		DIV	DL

		MOV	CH,BPTR [EBX].WHOUR
		MOV	DH,BPTR [EBX].WSECOND

		MOV	CL,BPTR [EBX].WMINUTE
		MOV	DL,AL			;CH=HOUR (0-23), CL=MIN (0-59), DH=SEC (0-59), DL=HUNDREDTHS (0-99)

		MOV	AL,CH
		MOV	CURN_HOUR,CH

		AND	EAX,0FFH
		MOV	CURN_MINUTE,CL

		SHL	EAX,6
		MOV	CURN_SECOND,DH

		OR	AL,CL
		MOV	CURN_HUNDREDTH,DL

		SHL	EAX,5

		SHR	DH,1

		OR	AL,DH
		POP	EBX

		MOV	CURN_TIME_DWD,EAX

		RET

GET_TIME_AND_DATE	ENDP


		.DATA?

SYSTEM_TIME	DD	4 DUP(?)

		END

